import VGE from '../../VGE';

export class Misc {
	constructor(viewer) {
		this.viewer = viewer;
	}

	getPerformance() {
		try {
			const viewer = this.viewer;

			const fps = VGE._fps || 60;
			const loadtime = viewer?.loadTime || 1000;
			const network = +(navigator.connection.downlink + Math.random() * 0.5).toFixed(2);

			return { fps: parseInt(fps), network, loadtime };
		} catch (e) {
			console.error(e.message);
		}
	}

	getScreenshot() {
		const canvas = this.viewer.canvas;

		return canvas.toDataURL('image/png');
	}
}
